Update log.md

20210119

A new fucntion named matchingvariablegeneralized(y, by, type = 'F', threshold = 1) has been updated. matchingvariable() can find as many obsearved data as possible that are not significantly different between only two conditions (or within one condition variable with two levels). However, sometimes there are more than two levels within one condition variable. In addition, usually there are more than one condition variable. In these situation, matchingvariable() can not satify the users, while matchingvariablegeneralized() can.

When using this function, users should set the parameter by as a list object which include the condition variables of interest.

set.seed(1234)
y = c(rnorm(100,0),
      rnorm(120,0.1),
      rnorm(120,0.2),
      rnorm(110,0.3),
      rnorm(110,0.2),
      rnorm(120,0.4))
by = cbind(c(rep('A1',340),rep('A2',340)),
           c(rep('B1',100),rep('B2',120),rep('B3',120),
             rep('B1',110), rep('B2',110), rep('B3',120)))
testdf = tibble(y,V1=by[,1],V2=by[,2])

testdf = testdf %>% 
  mutate(matchingtest = matchingvariablegeneralized(y = y, 
                                                    by = list(V1,V2), 
                                                    type = 'F',
                                                    threshold = 1.5)) %>%
  filter(matchingtest == 1)

20210117

A new function named matchingvalue(y, value, type='t', threshold = 1) has been updated. This function works in a similar way with matchingvariable(). It can find as many obsearved data (set using the parameter y in the function) as possible of which the mean is not significantly different with a given value (set using the parameter value in the function).

set.seed(1234)
y = rnorm(n = 200, mean = 0.5)

matchingvalue(y = y, value, type='t', threshold = 1)

20210107

A new function named matchingvariable(y = , by = , type = 't', threshold = 1) has been updated. It is very common in cognitive experiments that you need two sets of experimental materials that are equal in number and match on a particular attribute. You want to make sure that there is no significant difference between the two groups of materials in the (rating) score for this attribute, and you want to find as many materials as possible that meet this requirement. This function will help you do this efficiently.

This function will return a set of 0-1 vector, in which 1 means qualified, while 0 means unqualified.

You can use statistical t value (e.g. t < 1) to select the materials:

y1 = rnorm(100,mean = 0, sd = 1)
cond1 = rep('C1', 100)
y2 = rnorm(120,mean = 0.5, sd = 1)
cond2 = rep('C2', 120)
y = c(y1, y2)
by = c(cond1, cond2)
matchingvariable(y = y, by = by, type = 't', threshold = 1)

You can also use statistical p value (e.g. p > 0.1) to select the materials:

matchingvariable(y = y, by = by, type = 'p', threshold = 0.1)

20201217

A new function named PCOR(X,Y,...,Method = 'pearson', Alternative='two.sided') has been updated. It can perfrom the partial correlation analysis. The X and 'Y' are the two variables that the partial correlation is perfomed between. ... are the variables to be controlled. Method and Alternative parameters can be defined in the same way as the method and alternative ones in the base R function cor.test().

20201028

Critical update: A new function named MixedModelWrite2(Model = NULL, Data = NULL, Prefix = 'DV', compareModel = F, ModelnamesTocompare) has been created. It can output the information of fixed effects for more than one model in the form of docx document. This function requires export package and texreg package. But these can be automatically installed.

The information of parameters is following:

Here is one example:

library(YawMMF)
Model1 = lmer(data = DemoData, 
              DV~CondA+(1|subj)+(1|item))
Model2 = lmer(data = DemoData, 
              log(DV)~CondA+(1|subj)+(1|item))
MixedModelWrite2(Model = list(Model1, Model2),
                 Prefix = 'DV',
                 compareModel = T,
                 ModelnamesTocompare = c('Origin','Log'))

20201016

Notion that the parameter Type can only be defined as 'd' or 'r'.

Notion that the function will provide the equation of calculating accordingly, which will help researchers understand and check the results.

Here is an example:

library(YawMMF)
Model1 = lmer(data=DemoData, DV~CondA+(1|subj))
Model2 = glmer(data = DemoData2, DV~CondA+(1|subj),family = 'binomial')

# to calculate the cohen d value
EffectSize(Model = Model1, Type = 'd', GLMM = F)
EffectSize(Model = Model2, Type = 'd', GLMM = T)

# to calculate the r value
EffectSize(Model = Model1, Type = 'r', GLMM = F)
EffectSize(Model = Model2, Type = 'r', GLMM = T)

20200918

20200831

20200621

library(YawMMF)
DemoData %>% 
    Simplecoding(data = ., Factor = 'CondA,CondB') %>%
    MixedModelDummy(data = ., Fix_Factor = 'CondA,CondB',MatrixDesign = '*',ContrastsM = F) %>% 
    MixedModelDiag(data = ., 
                   DV = 'DV', 
                   IV = 'CondA*CondB',
                   randomfactor = 'subj,item',
                   randomeffect = '1+CondA1+CondB1+CondA1_CondB1,1+CondA1+CondB1+CondA1_CondB1',
                   PCAdeletecriterion = 0)

20200415

20200404

20200117

20200110



usplos/YawMMF documentation built on July 12, 2024, 1:35 a.m.